package com.ita.os.merchant.service.impl;

import com.ita.os.merchant.dao.MerchantDao;
import com.ita.os.merchant.dao.impl.MerchantDaoImpl;
import com.ita.os.merchant.exception.UserExistException;
import com.ita.os.merchant.po.Merchant;
import com.ita.os.merchant.service.MerchantService;

public class MerchantServiceImpl implements MerchantService{

	private MerchantDao merchantDao = new MerchantDaoImpl();
	
	@Override
	public Merchant findMerchant(String mname, String password) {
		return merchantDao.findMerchant(mname, password);
	}

	@Override
	public int addMerchant(Merchant merchant)  throws UserExistException  {
		if(merchantDao.findByName(merchant.getMname()) != null){
			throw new UserExistException("userNme is exist!!!");
		}
		return merchantDao.addMerchant(merchant);
	}

	@Override
	public int updateMerchant(Merchant merchant) {
		return merchantDao.updateMerchant(merchant);
	}

	@Override
	public Merchant findByName(String mname) {
		return merchantDao.findByName(mname);
	}
	

}
